package br.com.sgpv2.datasource.secretaria;

import java.util.ArrayList;
import java.util.List;

import br.com.sgpv2.entity.organograma.Secretaria;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRAbstractBeanDataSourceProvider;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;

public class SecretariaDataSource extends JRAbstractBeanDataSourceProvider{

	private List<Secretaria> secretarias;
	
	public SecretariaDataSource() {
		super(Secretaria.class);
	}
	
	@Override
	public JRDataSource create(JasperReport report) throws JRException {
		secretarias = new ArrayList<Secretaria>();
		Secretaria s1 = new Secretaria();
		s1.setDescricao("Secretaria 1");
		secretarias.add(s1);
		Secretaria s2 = new Secretaria();
		s2.setDescricao("Secretaria 2");
		secretarias.add(s2);
		
		return new JRBeanCollectionDataSource(secretarias);
	}

	@Override
	public void dispose(JRDataSource arg0) throws JRException {
		secretarias.clear();
		secretarias = null;
		
	}

}
